/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ecfdb;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author SIDALI
 */
@Entity
@Table(name = "acheteur", catalog = "mandataire", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Acheteur.findAll", query = "SELECT a FROM Acheteur a"),
    @NamedQuery(name = "Acheteur.findByIdacheteur", query = "SELECT a FROM Acheteur a WHERE a.idacheteur = :idacheteur"),
    @NamedQuery(name = "Acheteur.findByNom", query = "SELECT a FROM Acheteur a WHERE a.nom = :nom"),
    @NamedQuery(name = "Acheteur.findByDate", query = "SELECT a FROM Acheteur a WHERE a.date = :date"),
    @NamedQuery(name = "Acheteur.findBySolde", query = "SELECT a FROM Acheteur a WHERE a.solde = :solde")})
public class Acheteur implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idacheteur", nullable = false)
    private Integer idacheteur;
    @Column(name = "nom", length = 45)
    private String nom;
    @Column(name = "date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date date;
    @Column(name = "solde")
    private Integer solde;
    @OneToMany(mappedBy = "acheteur")
    private List<Vente> venteList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "acheteur")
    private List<Cajot> cajotList;

    public Acheteur() {
    }

    public Acheteur(Integer idacheteur) {
        this.idacheteur = idacheteur;
    }

    public Integer getIdacheteur() {
        return idacheteur;
    }

    public void setIdacheteur(Integer idacheteur) {
        this.idacheteur = idacheteur;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Integer getSolde() {
        return solde;
    }

    public void setSolde(Integer solde) {
        this.solde = solde;
    }

    @XmlTransient
    public List<Vente> getVenteList() {
        return venteList;
    }

    public void setVenteList(List<Vente> venteList) {
        this.venteList = venteList;
    }

    @XmlTransient
    public List<Cajot> getCajotList() {
        return cajotList;
    }

    public void setCajotList(List<Cajot> cajotList) {
        this.cajotList = cajotList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idacheteur != null ? idacheteur.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Acheteur)) {
            return false;
        }
        Acheteur other = (Acheteur) object;
        if ((this.idacheteur == null && other.idacheteur != null) || (this.idacheteur != null && !this.idacheteur.equals(other.idacheteur))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return getNom();
    }
    
}
